package com.sleepcamel.rest.domain.method.parameter;

import java.util.HashSet;
import java.util.Set;

import com.sleepcamel.rest.domain.IImportDependant;
import com.sleepcamel.rest.domain.ISourceCodeGenerable;
import com.sleepcamel.rest.domain.JavaClass;
import com.sleepcamel.rest.domain.NamedBaseBean;

public class MethodParameter extends NamedBaseBean implements ISourceCodeGenerable, IImportDependant {

	private JavaClass type;
	protected Set<String> interfaceImports = new HashSet<String>();
	protected Set<String> classImports = new HashSet<String>();

	public JavaClass getType() {
		return type;
	}

	public void setType(JavaClass type) {
		support.firePropertyChange("type", this.type, this.type = type);
	}

	@Override
	public Set<String> getClassImports() {
		classImports.clear();
		addClassImport(classImports,type);
		return classImports;
	}

	@Override
	public Set<String> getInterfaceImports() {
		interfaceImports.clear();
		addClassImport(interfaceImports,type);
		return interfaceImports;
	}
	
	protected void addClassImport(Set<String> set, JavaClass clazz){
		set.addAll(clazz.getClassImports());
	}

}
